IF (s1.class = Texts.Name) & ((s1.s[s1.len-1] = ".") OR (s1.nextCh = ";")) THEN pos := -1 END
END;
IF pos >= 0 THEN
INC(del); Texts.Delete(text, pos, pos+1);
Texts.OpenScanner(S, text, pos)
END
END
END; (* LOOP *)
Int(del); String(" semicolon"); IF del # 1 THEN String("s") END; String(" deleted"); Ln
END
END Semicolons;
PROCEDURE Format*;
(** Insert CR between (VAR | CONST | BEGIN | THEN | DO | LOOP) and following statement, if not only on one line *)
VAR s: Texts.Scanner; v: Viewers.Viewer; text: Texts.Text; del, pos: LONGINT;
BEGIN
v := Oberon.MarkedViewer();
IF (v IS MV.Viewer) & (v.dsc.next IS TF.Frame) THEN
text := v.dsc.next(TF.Frame).text; Texts.OpenScanner(s, text, 0); repl := 0;
LOOP
IF s.eot THEN EXIT END;
REPEAT Texts.Scan(S) UNTIL (s.class = Texts.Name) & ((s.s = "CONST") OR (s.s = "VAR") OR (s.s = "BEGIN") OR (s.s = "DO") OR (s.s = "THEN") OR (s.s = "LOOP") OR (s.s = "REPEAT")) OR (s.class = Texts.Char) & (s.c = "|") OR s.eot;
IF s.eot THEN EXIT END;
IF
IF (s.class = Texts.Char) & (s.c = "|") THEN
startPos := Texts.Pos(s)-1;
REPEAT Texts.Scan(s) UNTIL (s.class = Texts.Char) & (s.c = ":") OR s.eot
ELSE startPos := Texts.Pos(s)-s.len
END;
IF s.eot THEN EXIT END;
insertPos := Texts.Pos(s)-1; line := s.line;
REPEAT Texts.Scan(s) UNTIL s.eot OR s.line = line+1 END;
IF s.eot THEN EXIT END;
IF (s.class = Texts.Name) & ((s.s = "END") OR (s.s = "ELSE") OR (s.s = "ELSIF") OR (s.s = "UNTIL") OR (s.s = "TYPE") OR (s.s = "VAR") OR (s.s = "BEGIN"))
OR (s.class = Texts.Char) & (s.c = "|") THEN
INC(del); Texts.Delete(text, pos, pos+1);
Texts.OpenScanner(S, text, Texts.Pos(S))
END
END; (* LOOP *)
Int(del); String(" semicolon"); IF del # 1 THEN String("s") END; String(" deleted"); Ln
END
END Format;
PROCEDURE Deblank*; (** [num] | "^" Replace num (or 2) leading blanks in a line with 1 Tab *)